Ion Library Functions by Joe Wingbermuehle
See ion.txt for information about Ion.
See iondev.txt for developer information.

>Background
Ion has eight built in library routines to
make programs smaller and easier to write.
The function names are included in ion.inc
and you may call them or jump to them at
any time in your program provided that your
program does not use _insertmem or some
other function that moves memory directly
following your program.
The functions are:
	ionVersion
	ionRandom
	ionPutSprite
	ionLargeSprite
	ionGetPixel
	ionFastCopy
	ionDetect
	ionDecompress

>Usage
ionVersion:
	Returns version and compatibility numbers.
	Input:	nothing
	Output: hl=Ion version number (e.g 256=1.0)
		a=Ion compatibility number
		d=Library compatibility number
		e=number of library routines
	Destroys: a de hl

ionRandom:
	Generates an eight-bit random number.
	Much faster than the _random ROM call.
	Input:	b=upper bound
	Output: a=answer (0<=a<b)
		b=0
	Destroys af b

ionPutSprite:
	Draw a sprite to the graph buffer (XOR).
	Input:	b=sprite height
		a=x coordinate
		l=y coordinate
		ix->sprite
	Output:	Sprite is XORed to the graph buffer.
		ix->next sprite
	Destroys: af bc de hl ix

ionLargeSprite:
	Draw a variable width sprite to the graph buffer (XOR).
	This routine is slower than ionPutSprite.
	Input:	ix->sprite
		a=x coordinate
		l=y coordinate
		b=sprite height
		c=sprite width (in bytes, so divide by 8)
	Output:	sprite is XORed to the graph buffer
		ix->next sprite
	Destroys: af bc de hl ix af'

ionGetPixel:
	Get pixel offset and mask.
	Input:	a=x coordinate
		e=y coordinate
	Output:	a=pixel mask
		hl->offset (in the graph buffer)
	Destroys: af bc de hl

ionFastCopy:
	Copy the graph buffer to the screen, FAST!
	Input:	nothing
	Output:	graph buffer is copied to the screen
	Destroys: af bc de hl

ionDetect:
	Find a program file in the VAT.
	Input:	hl=place to begin search ((vat) first time)
		ix->detection string (zero terminated)
	Output:	de=place stopped + 1
		hl->program data (after detection string)
		z=0 for success, z=1 if failed
		Destroys: af bc de hl

ionDecompress:
	Decompress data.
	Input:	hl->compressed data
		de->place to load uncompressed data
		b=length of compressed data
		c=compression factor {1,3,15}
	Output:	data is decompressed
		hl->next byte of compressed data
	Destroys: af bc de hl

>History
Version 1.0 (libCompatability 0)
	-First release!
	-Eight routines.
Version 1.1 (libCompatability 0)
	-The ionDetect routine should work properly
	 on the TI-83 Plus now.
	-I slowed the ionFastCopy routine so that it
	 would not cause the screen to become
	 distorted, which happened on some calculators.

Joe Wingbermuehle
http://joewing.calc.org